package servlet;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import model.Pessoa;
import fachada.Fachada;

public class RemoverPessoa extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 2174579115584424646L;
	
	@Override
	protected void doPost(HttpServletRequest request, 
						  HttpServletResponse response)
						  throws ServletException, IOException {
		
		Fachada f = new Fachada();
		Pessoa p = new Pessoa();
		
		p.setEmail(request.getParameter("email"));
		
		if (f.removerPessoa(p)) {
			RequestDispatcher rd = request.getRequestDispatcher("pages_errors_sucess/sucesso_remover_pessoa.html");
			rd.forward(request, response);
		}else {
			response.sendRedirect("pages_errors_sucess/erro_remover_pessoa.html");
		}
		
	}
	
}
